﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace RoomService.Listings
{
    public partial class DisplayListings : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
            RoomSvc.Data.Listing[] listing = RoomService.Service.ServiceClient.GetListings();
            String[] Rate = new String[100];
            String[] Sqft = new String[100];
            String[] Roommates = new String[100];
            String[] Smoking = new String[100];
            String[] Furnished = new String[100];
            String[] DateExp = new String[100];
            
            int x = 0;
            /*
            foreach (RoomSvc.Data.Listing l in listing)
            {
                Rate[x] = l.listing_rate;
                Sqft[x] = listing[x].square_ft.ToString();
                x++;
            }*/
            /*
            for(x = 0; x <100; x++){
                Rate[x] = listing[x].listing_rate;
                Sqft[x] = listing[x].square_ft.ToString();
                Roommates[x] = listing[x].roommates;
                Smoking[x] = listing[x].smoking.ToString();
                Furnished[x] = listing[x].furnished.ToString();
                DateExp[x] = listing[x].date_listing_expire.ToString();
            }

            int rows = 100;
            int cols = 6;
            for (int j = 0; j < rows; j++)
            {
                TableRow r = new TableRow();
                //for (int i = 0; i < cols; i++)
                //{
                TableCell rates = new TableCell();
                rates.Controls.Add(new LiteralControl(Rate[j]));
                r.Cells.Add(rates);
                    
                    TableCell sqft = new TableCell();
                    sqft.Controls.Add(new LiteralControl(Sqft[j]));
                    r.Cells.Add(sqft);
                
                    TableCell room = new TableCell();
                    room.Controls.Add(new LiteralControl(Roommates[j]));
                    r.Cells.Add(room);

                    TableCell smoking = new TableCell();
                    smoking.Controls.Add(new LiteralControl(Smoking[j]));
                    r.Cells.Add(smoking);

                    TableCell furn = new TableCell();
                    furn.Controls.Add(new LiteralControl(Furnished[j]));
                    r.Cells.Add(furn);

                    TableCell dateexp = new TableCell();
                    dateexp.Controls.Add(new LiteralControl(DateExp[j]));
                    r.Cells.Add(dateexp);
                    //}
                table1.Rows.Add(r);
            }


            /*
            txt_rate.Text = listing[0].listing_rate;
            txt_ft.Text = listing[1].square_ft.ToString();
            txt_roommates.Text = listing[0].roommates;
            txt_smoking.Text = listing[0].smoking.ToString();
            txt_furn.Text = listing[0].furnished.ToString();
            txt_expire.Text = listing[0].date_listing_expire.ToString();
            */



            /*
            Table table = new Table();
            int rows = 5;
            int cells = 2;

            for (int t = 0; t < rows; t++)
            {
                // Create new row and add it to the table.
                TableRow tRow = new TableRow();
                table.Rows.Add(tRow);
                for (int i = 1; i <= cells; i++)
                {
                    // Create a new cell and add it to the row.
                    TableCell tCell = new TableCell();
                    tCell.Text = "Row " + t + ", Cell " + i;
                    tRow.Cells.Add(tCell);
                }
            }*/
            
        }
    }
}